<%= stylesheet_link_tag("contents_register") %>
      <div id="main">
      <% form_for :question, :url => {:action => 'update'} do |f| -%>

        <div class="subtitle">分類</div>
        <div class="qa_box">
          <%# category field %>
          <div class="label">カテゴリ</div>
          <div class="field">
            <%= select_tag "category",
               options_from_collection_for_select(Category.find(:all), :id, :name, @question.category_id)
            %>
          </div>

          <%# tag field%>
          <div class="label">タグ</div>
          <div class="field">
            <%= text_field_tag "tag", "", {:size => 20} %>
            ※ 「自分で登録」タグは自動でつきます。
          </div>
        </div>
        
        <div class="qa_box">
          <div class="subtitle">問題</div>
          <div class="label">問題文</div>
          <div class="field">
            <%= hidden_field_tag "question_id", @question.id %>
            <%= text_area_tag "question_ta",
              @question.question_text.gsub("<br />", "\n"),
              :size => "40x5" %>
          </div>
        </div>

        <div class="qa_box">
          <div class="subtitle">解答</div>
          <div class="label">回答方法</div>
          <div class="field">
            <%= select_tag "question_type",
              options_from_collection_for_select(QuestionType.find(:all),
              :id, :name,
              @question.question_type) %>
          </div>

          <%# TODO: 絶対もっとスッキリできるはず %>
          <div class="label">選択肢 ※ 正解にチェックを入れてください</div>
          <div class="field">
            <ul>
              <% @selections.each do |selection| %>
              <li>
                <div class="selection_box">
                  <input id="is_collect[<%=selection.id%>]" name="is_collect[<%=selection.id%>]" type="checkbox" <%= "checked" if selection.is_collect == 1 %> />
                  <%= text_field_tag "selection[#{selection.id}]", selection.selection_text, {:size => 20} %><br /></div></li>
              <% end %>
          </div>

          <div class="label">解答(入力の場合)</div>
          <div class="field">
            <%= text_area_tag "answer_ta", "", :size => "40x3" %>
          </div>
        </div>

        <div class="qa_box">
          <div class="subtitle">解説</div>
          <div class="label">解説文</div>
          <div class="field">
            <%= text_area_tag "description_ta",
              @description.description_text.gsub("<br />", "\n"),
              :size => "40x5" %>
          </div>
        </div>

        <input type="submit" value="更新する"/>
      </div>
    <% end -%>
